﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Ink;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;

namespace DrawingCore
{
    class GraphicHanddraw : GraphicsRectangleBase
    {
        private Stroke _Stroke;

        private InkCanvas _InkCanvas;

        public GraphicHanddraw(Stroke stroke, InkCanvas canvas){
            _Stroke = stroke;
            _InkCanvas = canvas;
            Rect bounds = _Stroke.GetBounds();
        }

        public override bool Contains(System.Windows.Point point)
        {
            return _Stroke.HitTest(point);
        }

        public override void Draw(System.Windows.Media.DrawingContext drawingContext)
        {
            _Stroke.Draw(drawingContext);
            base.Draw(drawingContext);
        }

        public override bool IntersectsWith(System.Windows.Rect rectangle)
        {
            return _Stroke.HitTest(rectangle, 60);
        }

        public override PropertiesGraphicsBase CreateSerializedObject()
        {
            throw new NotImplementedException();
        }

        private void Scale(double horizontal_scale, double vertical_scale)
        {
            Matrix m = new Matrix();
            m.Scale(horizontal_scale, vertical_scale);
            _Stroke.Transform(m, true);
        }

        private void Move(double horizontal, double vertical){
            Matrix m = new Matrix();
            m.OffsetX = horizontal;
            m.OffsetY = vertical;
            _Stroke.Transform(m, true);
        }

        public override void Rotate(Point center, Point orignPoint, Point curPoint)
        {
            double degree = this.getDegree(center, orignPoint, curPoint);
            Matrix m = new Matrix();
            m.Rotate(degree);
            _Stroke.Transform(m, true);
            RefreshDrawing();
        }
    }
}
